A few changes to the new 'guest handle' interface:
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Thu, 2 Mar 2006 13:43:24 +0000 (14:43 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Thu, 2 Mar 2006 13:43:24 +0000 (14:43 +0100)
 DEFINE_GUEST_HANDLE -> define_guest_handle

 GUEST_HANDLE        -> guest_handle

 New __define_guest_handle allows handle name different from
 encapsulated type's name (useful for awkward typenames).

 Got rid of xen_ulong, now use guest_handle(ulong).

Signed-off-by: Keir Fraser <keir@xensource.com>
xen/arch/x86/mm.c
xen/arch/x86/x86_32/mm.c
xen/arch/x86/x86_64/mm.c
xen/common/memory.c
xen/include/asm-x86/mm.h
xen/include/public/memory.h
xen/include/public/xen.h
xen/include/xen/guest_access.h
xen/include/xen/sched.h

index 60a324cf7976b64f419bca30bc1e0d9ac9fd7f50..60e8e778b5d4cba1bf864e81fd76add4b21dbe8c 100644 (file)
@@ -2788,7 +2788,7 @@ long do_update_descriptor(u64 pa, u64 desc)
 }
 
 
-long arch_memory_op(int op, GUEST_HANDLE(void) arg)
+long arch_memory_op(int op, guest_handle(void) arg)
 {
     struct xen_reserved_phys_area xrpa;
     unsigned long pfn;
index 19dfc0170e90fde75ee6e51eac7a120cf50b5648..2df32d9d8fc280ee2b939d98ae3527ac1c2bfdb6 100644 (file)
@@ -192,7 +192,7 @@ void subarch_init_memory(struct domain *dom_xen)
     }
 }
 
-long subarch_memory_op(int op, GUEST_HANDLE(void) arg)
+long subarch_memory_op(int op, guest_handle(void) arg)
 {
     struct xen_machphys_mfn_list xmml;
     unsigned long mfn;
index 7e826da8b098ef85e16eb899a18b6dd720b268f8..2a61d4132458525bfce2ecbe429bbef9bf394132 100644 (file)
@@ -183,7 +183,7 @@ void subarch_init_memory(struct domain *dom_xen)
     }
 }
 
-long subarch_memory_op(int op, GUEST_HANDLE(void) arg)
+long subarch_memory_op(int op, guest_handle(void) arg)
 {
     struct xen_machphys_mfn_list xmml;
     l3_pgentry_t l3e;
index 4d96f97465c8ac8fbf8961a5f8705e45cc30407b..3c0320ee392572bebec58287f9703328a6a990b0 100644 (file)
@@ -31,7 +31,7 @@
 static long
 increase_reservation(
     struct domain *d, 
-    GUEST_HANDLE(xen_ulong) extent_list,
+    guest_handle(ulong) extent_list,
     unsigned int   nr_extents,
     unsigned int   extent_order,
     unsigned int   flags,
@@ -80,7 +80,7 @@ increase_reservation(
 static long
 populate_physmap(
     struct domain *d, 
-    GUEST_HANDLE(xen_ulong) extent_list,
+    guest_handle(ulong) extent_list,
     unsigned int  nr_extents,
     unsigned int  extent_order,
     unsigned int  flags,
@@ -141,7 +141,7 @@ populate_physmap(
 static long
 decrease_reservation(
     struct domain *d,
-    GUEST_HANDLE(xen_ulong) extent_list,
+    guest_handle(ulong) extent_list,
     unsigned int   nr_extents,
     unsigned int   extent_order,
     unsigned int   flags,
@@ -198,7 +198,7 @@ decrease_reservation(
 
 static long
 translate_gpfn_list(
-    GUEST_HANDLE(xen_translate_gpfn_list_t) uop, unsigned long *progress)
+    guest_handle(xen_translate_gpfn_list_t) uop, unsigned long *progress)
 {
     struct xen_translate_gpfn_list op;
     unsigned long i, gpfn, mfn;
@@ -257,7 +257,7 @@ translate_gpfn_list(
     return 0;
 }
 
-long do_memory_op(unsigned long cmd, GUEST_HANDLE(void) arg)
+long do_memory_op(unsigned long cmd, guest_handle(void) arg)
 {
     struct domain *d;
     int rc, op, flags = 0, preempted = 0;
index 040d919626bb0bbec08092c7ea348a028f2bcbd7..1a65b04161f96f233c6b813633bff7cd7dd5a9d4 100644 (file)
@@ -380,7 +380,7 @@ void propagate_page_fault(unsigned long addr, u16 error_code);
 int __sync_lazy_execstate(void);
 
 /* Arch-specific portion of memory_op hypercall. */
-long arch_memory_op(int op, GUEST_HANDLE(void) arg);
-long subarch_memory_op(int op, GUEST_HANDLE(void) arg);
+long arch_memory_op(int op, guest_handle(void) arg);
+long subarch_memory_op(int op, guest_handle(void) arg);
 
 #endif /* __ASM_X86_MM_H__ */
index 639c293b27095453165d4f7930fa749c4397ed65..e923731fbd6edbbd3d6c398d404e8b8c35c19850 100644 (file)
@@ -29,7 +29,7 @@ typedef struct xen_memory_reservation {
      *   OUT: GMFN bases of extents that were allocated
      *   (NB. This command also updates the mach_to_phys translation table)
      */
-    GUEST_HANDLE(xen_ulong) extent_start;
+    guest_handle(ulong) extent_start;
 
     /* Number of extents, and size/alignment of each (2^extent_order pages). */
     unsigned long  nr_extents;
@@ -50,7 +50,7 @@ typedef struct xen_memory_reservation {
     domid_t        domid;
 
 } xen_memory_reservation_t;
-DEFINE_GUEST_HANDLE(xen_memory_reservation_t);
+define_guest_handle(xen_memory_reservation_t);
 
 /*
  * Returns the maximum machine frame number of mapped RAM in this system.
@@ -86,7 +86,7 @@ typedef struct xen_machphys_mfn_list {
      * any large discontiguities in the machine address space, 2MB gaps in
      * the machphys table will be represented by an MFN base of zero.
      */
-    GUEST_HANDLE(xen_ulong) extent_start;
+    guest_handle(ulong) extent_start;
 
     /*
      * Number of extents written to the above array. This will be smaller
@@ -94,7 +94,7 @@ typedef struct xen_machphys_mfn_list {
      */
     unsigned int nr_extents;
 } xen_machphys_mfn_list_t;
-DEFINE_GUEST_HANDLE(xen_machphys_mfn_list_t);
+define_guest_handle(xen_machphys_mfn_list_t);
 
 /*
  * Returns the base and size of the specified reserved 'RAM hole' in the
@@ -115,7 +115,7 @@ typedef struct xen_reserved_phys_area {
     /* Base and size of the specified reserved area. */
     unsigned long first_gpfn, nr_gpfns;
 } xen_reserved_phys_area_t;
-DEFINE_GUEST_HANDLE(xen_reserved_phys_area_t);
+define_guest_handle(xen_reserved_phys_area_t);
 
 /*
  * Translates a list of domain-specific GPFNs into MFNs. Returns a -ve error
@@ -130,15 +130,15 @@ typedef struct xen_translate_gpfn_list {
     unsigned long nr_gpfns;
 
     /* List of GPFNs to translate. */
-    GUEST_HANDLE(xen_ulong) gpfn_list;
+    guest_handle(ulong) gpfn_list;
 
     /*
      * Output list to contain MFN translations. May be the same as the input
      * list (in which case each input GPFN is overwritten with the output MFN).
      */
-    GUEST_HANDLE(xen_ulong) mfn_list;
+    guest_handle(ulong) mfn_list;
 } xen_translate_gpfn_list_t;
-DEFINE_GUEST_HANDLE(xen_translate_gpfn_list_t);
+define_guest_handle(xen_translate_gpfn_list_t);
 
 #endif /* __XEN_PUBLIC_MEMORY_H__ */
 
index a629a1e26a449b8f652a55d409960ec2efc645bd..907ac5cc6b78485004f0eabf5884d695147a276f 100644 (file)
 #define __XEN_PUBLIC_XEN_H__
 
 #ifdef __XEN__
-#define DEFINE_GUEST_HANDLE(type) struct __guest_handle_ ## type { type *p; }
-#define GUEST_HANDLE(type)        struct __guest_handle_ ## type
+#define __define_guest_handle(name, type) \
+    typedef struct { type *p; } __guest_handle_ ## name
 #else
-#define DEFINE_GUEST_HANDLE(type)
-#define GUEST_HANDLE(type)        type *
+#define __define_guest_handle(name, type) \
+    typedef type * __guest_handle_ ## name
 #endif
 
+#define define_guest_handle(name) __define_guest_handle(name, name)
+#define guest_handle(name)        __guest_handle_ ## name
+
 #ifndef __ASSEMBLY__
-/* Guest handle for unsigned long pointer. Define a name with no whitespace. */
-typedef unsigned long xen_ulong;
-DEFINE_GUEST_HANDLE(xen_ulong);
-/* Guest handle for arbitrary-type pointer (void *). */
-DEFINE_GUEST_HANDLE(void);
+/* Guest handles for primitive C types. */
+__define_guest_handle(uchar, unsigned char);
+__define_guest_handle(uint,  unsigned int);
+__define_guest_handle(ulong, unsigned long);
+define_guest_handle(char);
+define_guest_handle(int);
+define_guest_handle(long);
+define_guest_handle(void);
 #endif
 
 #if defined(__i386__)
index 3a5bba9f0b23f6250390e52d1c371280767244ca..d824421bf0e3c18d4037987b02b4be5bdd5d4da5 100644 (file)
@@ -18,7 +18,7 @@
 /* Cast a guest handle to the specified type of handle. */
 #define guest_handle_cast(hnd, type) ({         \
     type *_x = (hnd).p;                         \
-    (GUEST_HANDLE(type)) { _x };                \
+    (guest_handle(type)) { _x };                \
 })
 
 /*
index 2d9c5564d1228839d855171a9f3a1bcbe26ddd38..3acd0d79a0a97776fc4e2eb720f3c449e7efd80c 100644 (file)
@@ -311,7 +311,7 @@ void startup_cpu_idle_loop(void);
  *  'i' [unsigned] {char, int}
  *  'l' [unsigned] long
  *  'p' pointer (foo *)
- *  'h' guest handle (GUEST_HANDLE(foo))
+ *  'h' guest handle (guest_handle(foo))
  */
 unsigned long hypercall_create_continuation(
     unsigned int op, const char *format, ...);